package com.itmd.dao;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.test.context.ContextConfiguration;

@Component
@ContextConfiguration("classpath:applicationContext.xml")
public class Account implements IAccount {
    private String name;
    private double money;

    @Autowired
    private  JdbcTemplate jdbcTemplate;

    public Account() {

    }

//    public void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
//        this.jdbcTemplate = jdbcTemplate;
//    }

    public String getName() {
        return name;
    }

    public double getMoney() {
        return money;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setMoney(double money) {
        this.money = money;
    }

    @Override
    public void in(String inMan, double inmoney) {
      jdbcTemplate.update("update t_account set money=money+? where name=?",inmoney,inMan);
    }

    @Override
    public void out(String outMan, double outmoney) {
       jdbcTemplate.update("update t_account set money=money-? where name=?",outmoney,outMan);
    }
}
